<?php

class ProductController extends Controller
{
	/**
	 * Declares class-based actions.
	 */
	public function actions()
	{
		return array(
			// They can be accessed via: index.php?r=site/page&view=FileName
			'page'=>array(
				'class'=>'CViewAction',
			),
		);
	}

	/**
	 * This is the default 'index' action that is invoked
	 * when an action is not explicitly requested by users.
	 */
	public function actionIndex()
	{
		$products = Product::model()->findAllByAttributes(array(
        	'status'=>Product::STATUS_ACTIVED,
		));

		$this->render('index', array(
        	'products'=>$products,
		));
	}

	public function actionDetail($id)
	{
        $p = Product::model()->findByPk($id);

        if(!empty($p)){
			$this->render('detail',array('product'=>$p));
        }
	}
}